package com.rose.controller;

import com.rose.common.constant.AuthServerConstant;
import com.rose.common.vo.MemberRsepVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author rose
 * @create 2022/3/6
 */
@Slf4j
@Controller
@RequestMapping("/oauth2.0")
public class Oath2Controller {

    @GetMapping("/logout")
    public String login(HttpSession session){
        if(session.getAttribute(AuthServerConstant.LOGIN_USER) != null){
            log.info("\n[" + ((MemberRsepVo)session.getAttribute(AuthServerConstant.LOGIN_USER)).getUsername() + "] 已下线");
        }
        session.invalidate();
        return "redirect:http://auth.mall.com/login.html";
    }

}
